%clear all; clc;close all;
%Updated: 11/30/2021

alpha = 0.75;
pm     = 1;
gamma  = 0.43;
omegac = 0.3;
mu     = 1;
lambda = 0.184;
r      = 0.02;

% plot time series
seriesp   = load('seriesp.txt');
seriesr   = load('seriesr.txt');
seriesh   = load('seriesh.txt');
seriesb   = load('seriesb.txt');
seriesct  = load('seriesct.txt');
seriesgn  = load('seriesgn.txt');
seriestau = load('seriestau.txt');    
seriesa   = load('seriesa.txt');    
seriesbor = load('seriesbor.txt');    

n = length(seriesp);

seriescn= seriesh.^alpha-seriesgn;
seriesy = seriesa+seriesp.*seriesh.^alpha; % -pm*seriesm;
seriesgny = seriesgn./seriesy;

time =1:n;

ValueArray1 = {'-';'blue';1.5}';
ValueArray2 = {'-','--';'red','blue';1.5,1.5}';
ValueArray3 = {'-','--','-';'red','blue','black';1.5,1.5,1.5}';

%to ensure plot if no default occurs
seriesbor = 1-seriesbor;
seriesbor(199)=1;
seriesbor(200)=0;
seriesh(200) = 0;
seriesr(200) = 0.1;
ntime = 200;

nameFig = char([char(label_model) '_' char(label_graph)]);
figure('name',nameFig);
subplot(3,2,1); 
shadedTimeSeries(time,seriesa',seriesbor',[],{[]}, [0.9 0.9 0.9], 3);title('y^T');
AX1 = gca;box on;
set(AX1,'YTick',0.85:0.1:1.15);
axis(AX1, [time(1) time(ntime) 0.85 1.15]);
subplot(3,2,2);
shadedTimeSeries(time,seriesp',seriesbor',[],{[]}, [0.9 0.9 0.9], 3);title('p^N');
AX1 = gca;box on;
set(AX1,'YTick',0:0.2:1);
axis(AX1, [time(1) time(ntime) 0.95*min(seriesp) 1.05*max(seriesp)]);
subplot(3,2,3);
shadedTimeSeries(time,seriesct',seriesbor',[],{[]}, [0.9 0.9 0.9], 3);title('c^T');
AX1 = gca;box on;
set(AX1,'YTick',0.75:0.25:1.25);
axis(AX1, [time(1) time(ntime) 0.75  1.25]); 
subplot(3,2,4); 
shadedTimeSeries(time,seriesh',seriesbor',[],{[]}, [0.9 0.9 0.9], 3);title('h,c^N & g^N');
AX1 = gca;box on;
axis(AX1, [time(1) time(ntime) 0 1.05]);
hold on;
H0 = line(time,seriesh','Color','b','LineWidth',2);
H1 = line(time,seriescn','Color','r','LineWidth',2,'LineStyle','--');
H2 = line(time,seriesgn','Color','g','LineWidth',2,'LineStyle',':');
hh = [H0, H1,H2];
legend(hh,'h','c_N','g_N','Location','SouthEast','Orientation','Horizontal');
AX1 = gca;box on;
axis(AX1, [time(1) time(ntime) 0 1.05]);
subplot(3,2,5); 
shadedTimeSeries(time,seriesr',seriesbor',[],{[]}, [0.9 0.9 0.9], 3);title('spreads');
AX1 = gca;box on;
set(AX1,'YTick',0.0:0.025:0.1);
axis(AX1, [time(1) time(ntime) 0 0.1]);
subplot(3,2,6); P=plot(time,-seriesb);title('b');
shadedTimeSeries(time,-seriesb',seriesbor',[],{[]}, [0.9 0.9 0.9], 3);title('b');
AX1 = gca;box on;
axis(AX1, [time(1) time(ntime) 0 max(-seriesb)]);
saveas(gcf, fullfile(plot_path, nameFig),format_chart);
